import { ref } from 'vue'
import { defineStore } from 'pinia'

export const commonStore = defineStore('common', () => {
    // 菜单
    let menus = ref(JSON.parse(sessionStorage.getItem('menus') || '[]'))

    function getMenus() {
        if (this.menus.length !== 0) return this.menus
        this.menus = JSON.parse(sessionStorage.getItem('menus') || '[]')
        return this.menus
    }

    return {
        menus,
        getMenus
    }
})